package study.config.apollo.controller;

import com.ctrip.framework.apollo.Config;
import com.ctrip.framework.apollo.spring.annotation.ApolloConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Set;

@Slf4j
@RestController
public class AnnotationController {

    @ApolloConfig("config.yml")
    private Config config;

    @RequestMapping("/annotation")
    public String config() {
        Set<String> pros = config.getPropertyNames();
        pros.forEach(e -> {
            log.info("{}= {}", e, config.getProperty(e, null));
        });
        return "ok";
    }
}
